

$(function () {
    let goodsdata = getQueryString('productId')
init()
    function init() {
        thislist()
        getgoods()
        review()
    }

    //获取商品数据
    function getgoods() {
        $.ajax({
            url:"http://193.112.55.79:9090/api/getproduct",
            data:{productid:goodsdata},
            success:(res)=>{
                let data = res.result[0]                
                let html = template('goodData',data)
                $('.mm_goodData').html(html)
                
            }
        })
    }
    //获取沙雕评论
    function review() {
        $.ajax({
            url:"http://193.112.55.79:9090/api/getproductcom",
            data:{productid:goodsdata},
            success:(res)=>{
                let data = res.result
                console.log(res);
                
                let html2 = template('netizen',data)
                $('.user_review').html(html2)  
                
            }
        })
    }



    function thislist() {
        let thislist = getQueryString('category')
        $('.thislist').text(thislist)
    }
    function getQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        // if (r != null) return unescape(r[2]);
        if (r != null) return decodeURI(r[2]);
        return null;
    }
})













